﻿<UserControl x:Class="AttachedErrorMessageDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:IC="clr-namespace:Silverlight.InputCtrl;assembly=Silverlight.InputCtrl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    mc:Ignorable="d" d:DesignWidth="540" >
    <Grid x:Name="LayoutRoot" IC:ValidatorService.NewContext="True" Background="#FFFCFCFC" Margin="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="260"/>
            <ColumnDefinition Width="68"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="72" />
            <RowDefinition Height="58"/>
            <RowDefinition Height="*"  />
        </Grid.RowDefinitions>
        <StackPanel Margin="5,0,0,0" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Top">
            <Button x:Name="BntVldAll" Margin="0" Content="Validate All" FontSize="12" Click="BntVldAll_Click"/>
            <Button x:Name="BntResetAll" Margin="10,0,0,0" VerticalAlignment="Top" Content="Reset Validators" d:LayoutOverrides="Width" FontSize="12" Click="BntResetAll_Click"/>
        </StackPanel>
        <StackPanel Orientation="Vertical" Margin="5,0,0,10" Grid.Row="0" d:LayoutOverrides="GridBox">
            <TextBlock Text="Enter a Text (Min. 3 caracters and Max. 8 caracters)" TextWrapping="Wrap" FontSize="12" Margin="0,0,-76,0"/>
            <TextBox x:Name="TextInput" FontSize="12" Background="#FFECE8E8" Margin="0">
                <IC:ValidatorService.Validators>
                    <IC:ValidatorCollection>
                        <IC:LengthValidator MinLength="3" MaxLength="8" ErrorMessage="Text size shold be between 3 and 8 caracters" />
                    </IC:ValidatorCollection>
                </IC:ValidatorService.Validators>
				<IC:ValidatorService.behavior>
					<IC:Behaviortrigger MessageTooltip="False"/>
				</IC:ValidatorService.behavior>
            </TextBox>
        </StackPanel>
        <StackPanel Orientation="Vertical" Grid.Row="2" Grid.ColumnSpan="3">
            <controls:TabControl x:Name="TabCode" Height="230" Margin="0,0,0,5">
                <controls:TabItem Header="Xaml Code" Foreground="#FF050505">
                    <Grid>
                        <ScrollViewer x:Name="ScrllXaml" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
                            <TextBox x:Name="LblXaml" TextWrapping="NoWrap"  FontSize="12" FontWeight="Bold" IsReadOnly="True" AcceptsReturn="True" />
                        </ScrollViewer>
                    </Grid>
                </controls:TabItem>
                <controls:TabItem Header="C# Code" Foreground="#FF050505">
                    <Grid>
                        <ScrollViewer x:Name="ScrllCode" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
                            <TextBox x:Name="LblCode" TextWrapping="NoWrap"  FontSize="12" FontWeight="Bold" IsReadOnly="True" AcceptsReturn="True" />
                        </ScrollViewer>
                    </Grid>
                </controls:TabItem>
            </controls:TabControl>
            <StackPanel Margin="5,5,0,0" Orientation="Horizontal">
                <Button x:Name="BntSelectAll" Content="Select  Text" Click="BntSelectAll_Click"/>
                <TextBlock Text="Use Ctrl +C to Copy from clipboad" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,0,0,0" FontWeight="Bold" Foreground="#FF5F5050"/>
            </StackPanel>
        </StackPanel>
        <Border x:Name="BorderMsgErro" Margin="5,5,5,0" Grid.Column="2" Background="#FFFFDD00" BorderBrush="Black" BorderThickness="2" CornerRadius="20" VerticalAlignment="Top" Height="77" Grid.RowSpan="2">
			<IC:ValidatorService.ElementErrorMessage>
				<IC:ValidatorErrorMessage ElementError="StkError" ElementValidator="TextInput" ErrorBackground="#FFFFDD00" ErrorForeground="Black" ErrorFontSize="12" ErrorFontWeight="Bold"  />
			</IC:ValidatorService.ElementErrorMessage>
        	<StackPanel Margin="0">
        		<TextBlock FontSize="12" Foreground="Black" Text="Custom Message Error" TextWrapping="Wrap" FontWeight="Bold" HorizontalAlignment="Center" RenderTransformOrigin="0,0"/>
        		<StackPanel x:Name="StkError" Height="100" Margin="0,2,0,0"/>
        	</StackPanel>
        </Border>
    </Grid>
</UserControl>
